import torch
import torch.nn as nn


# 定义一个简单的神经网络模型
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.fc1 = nn.Linear(10, 20)
        self.fc2 = nn.Linear(20, 30)

    def forward(self, x):
        x = self.fc1(x)
        x = self.fc2(x)
        return x


import torch
from torch import nn
import torch.nn.functional as F

eps = 0.0001

class PolicyNet(torch.nn.Module):
    def __init__(self, state_dim, hidden_dim):
        super(PolicyNet, self).__init__()
        self.project = torch.nn.Sequential(
            nn.Linear(state_dim, hidden_dim),
            nn.ReLU(),
            nn.Linear(hidden_dim, hidden_dim),
            nn.ReLU(),
            # nn.Linear(hidden_dim, hidden_dim),
            # nn.ReLU(),
            nn.Linear(hidden_dim, 1),
            nn.Sigmoid()
        )

    def forward(self, x):
        x = self.project(x)
        return x


# 创建一个模型实例
# model = Net()
state_dim, hidden_dim = 10,20
model = PolicyNet(state_dim, hidden_dim )
# 打印模型参数
params = model.state_dict()
# print(params)
m=torch.mean(params['project.4.weight'].view(-1))
s=torch.std(params['project.4.weight'].view(-1))
print(m,s)
# a = torch.normal(m,s,size=params['fc2.weight'].shape)
# print('a=',a)
# b = a + params['fc2.weight']
# print('b=',b)
# # for name, param in params.items():
# #     print(name, param)
